package edu.gatech.cs2340.group7.wheresmystuffapp.presenters;

import android.content.Intent;
import edu.gatech.cs2340.group7.wheresmystuffapp.model.Account;
import edu.gatech.cs2340.group7.wheresmystuffapp.model.DataManager;
import edu.gatech.cs2340.group7.wheresmystuffapp.views.AccountInformationView;
import edu.gatech.cs2340.group7.wheresmystuffapp.views.ChangePasswordView;
import edu.gatech.cs2340.group7.wheresmystuffapp.views.LoginView;
/**
 * This does all the work for the account information screen
 * @author Nick
 *
 */
public class AccountInformationPresenter {

	private AccountInformationView myView;

	public AccountInformationPresenter(AccountInformationView v) {
		myView = v;
	}

	/**
	 * logs the current user out of the app
	 */
	public void logout() {
		Intent intent = new Intent(myView, LoginView.class);
		intent.setPackage(myView.getPackageName());
		Account a = DataManager.getCurrentAccount();
		a.setLoginAttempts(0);
		DataManager.setCurrentAccount(null);
		myView.startActivity(intent);
	}

	/**
	 * Takes the user to a screen where they can change their password
	 */
	public void changePassword() {
		Intent intent = new Intent(myView, ChangePasswordView.class);
		intent.setPackage(myView.getApplication().getPackageName());
		myView.startActivity(intent);
	}
}
